<?php
use App\Models\Category;

return [
    'title' => '分类',
    'single' => '分类',
    'model' => Category::class,

    //对CURD 动作的单独权限控制,其他动作不指定默认通过
    'action_permissions' => [
        'delete' => function () {
            //只有站长才有权删除分类
            return Auth::user()->hasRole('Founder');
        }
    ],

    'columns' => [
        'id' => [
            'title' => 'ID'
        ],

        'name' => [
            'title' => '名称',
            'sortable' => false,
        ],

        'description' => [
            'title' => '描述',
            'sortable' => false,
        ],

        'operation' => [
            'title' => '管理',
            'sortable' => false,
        ]

    ],

    'edit_fields' => [
        'name' => [
            'title' => '名称',
        ],

        'description' => [
            'title' => '描述',
            'type' => 'textarea',
        ],
    ],

    'filters' => [
        'id' => [
            'title' => '分类ID',
        ],

        'name' => [
            'title' => '分类名称',
        ]
    ],

    'rules' => [
        'name' => 'required|min:1|unique:categories',
    ],

    'messages' => [
        'name.required' => '请确保名字至少一个字符以上',
        'name.unique' => '分类名在数据已存在,请选择其他名称',
    ]
];
